﻿/**
* Vista asociada al contenedor
* de un proyecto listado
* en el aplicativo.
*/
Ext.define("entgpv11.view.ContentMenu01.NotesContainer", {
    extend: "Ext.Container",
    alias: "widget.notescontainer",
	requires: [
       	'entgpv11.view.ContentMenu01.ItemsList'
    ],
	config: {
	    dataArguments:
        {
				iProgramaId:"0",	
				iEjeId:"0",	
				iTipoId:"0",	
				iEstadoId:"0",	
				sText:"",	
				IdEmp:""
		},
        layout: {
            type: 'fit'
        },
		rol:'ADM'
    },
	initialize: function () {
	try
    {

            this.callParent(arguments);
		    this.setMasked({
		      xtype:'loadmask',
		      message:'Cragando..'
            });

            this.backButton =  {
                xtype: "button",
                iconCls: "reply", iconMask: true,
                ui: "back",
                handler: this.onBackButtonTap,
                scope: this
            };
            this.exitButton = {
                xtype: "button",
                ui: 'decline',
                iconCls: "delete",iconMask: true,
                handler: this.onExitButtonTap,
                scope: this
            };
            this.topToolbar = {
                xtype: "toolbar",
                title: 'Proyectos',
                docked: "top",
                items: [
			        this.backButton,
                    { xtype: 'spacer' },
                    this.exitButton
                ]
            };
		    //
		    var storeList = Ext.getStore('Notes');
	        //Apply the params
		    APP_GLOBAL.SetProxyExtraParams(storeList, this.getDataArguments());
		    //Reload your store
		    storeList.load();
		    this.lblInfo =  {
		        docked: 'top',
                height: 80,
			    xtype: 'fieldset',
			    title: 'Proyectos',
			    instructions: 'Selecione un item'
		    };
            var notesList = {
                xtype: "itemslist",
                store: storeList,
			    height: "95%",
                listeners: {
                    disclose: { fn: this.onNotesListDisclose, scope: this }
                }
            };
            var bottomToolbar = {
                xtype: "toolbar",
                docked: "bottom",
                items: []
            };
            this.add([this.topToolbar,this.lblInfo,notesList,bottomToolbar]);
		    this.unmask();
        } catch (ex) {
		    APP_GLOBAL.SetLog('NotesContainer.initialize::' + ex);
        }

    },
	onBackButtonTap: function () {
        this.fireEvent("backButtonTapCommand", this);
    },
    onNotesListDisclose: function (list, record, target, index, evt, options) {
        this.fireEvent('editNoteCommand', this, record,this.getRol());
    },
    onExitButtonTap: function () {
        this.fireEvent("exitButtonTapCommand", this);
    }
    
});